function APPFun() {
	return {
		ajax: function(cmd, param, successCallback, errorCallback, IP, data) {
			uni.getNetworkType({
				success: function(res) {
					if (res.networkType === 'none') {
						uni.showToast({
							title: '无网络连接',
							icon: 'none'
						});
						if (errorCallback) errorCallback({
							msg: '无网络连接'
						});
						return;
					}
					var url = ''
					if (IP) {
						if (data == 1) {
							url = IP + '?cmdname=' + cmd;
						} else if (data == 2) {
							url = IP + '?cmd=' + cmd;
						} else {
							url = IP
						}
					} else {
						url = uni.getStorageSync('IPAgreement') + uni.getStorageSync('serverIP') +
							'/Frame/SqlData?cmdname=' + cmd;
					}


					if (uni.getStorageSync('UserInfo')) {
						if (!param.hasOwnProperty("P_UserID")) {
							param.P_UserID = uni.getStorageSync('UserInfo').UserID;
						}
						if (!param.hasOwnProperty("P_UserName")) {
							param.P_UserName = uni.getStorageSync('UserInfo').UserName;
						}
						if (!param.hasOwnProperty("P_UserCode")) {
							param.P_UserCode = uni.getStorageSync('UserInfo').UserCode;
						}

					}

					uni.request({
						url: url,
						data: param,
						method: 'POST',
						timeout: 10000,
						header: {
							'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
						},
						success: (ret) => {
							// console.log(ret)
							if (ret) {
								if (ret.data.status == 200) {
									if (successCallback) successCallback(ret.data.data);
								} else {
									uni.showToast({
										title: cmd + '\n' + uni.getStorageSync(
												'serverIP') + '\n' +
											'错误代码1:' +
											'\n' + JSON.stringify(ret),
										icon: 'none'
									});
									if (errorCallback) errorCallback(ret.data);
								}
							} else {
								if (errorCallback) {
									errorCallback(err);
								} else {
									console.log(JSON.stringify(err))
								}
							}
						}
					});
				},
				fail: function() {
					uni.showToast({
						title: '无法获取网络状态',
						icon: 'none'
					});
					if (errorCallback) errorCallback({
						msg: '无法获取网络状态'
					});
					return;
				}
			})
		}
	}
}

export default APPFun();